﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;

namespace TimeCounterISM
{

    public class TimeCounterISMNode : TimeCounter
    {
        public string NextNodeName { private set; get; }

        public UnityEvent ReadyNode { private set; get; }
        public UnityEvent RunningNode { private set; get; }
        public UnityEvent ClearNode { private set; get; }



        public override void Run()
        {
            WatchNodeEvent();
            base.Run();
        }

        public void SetNextNode(string nextNode)
        {
            NextNodeName = nextNode;
        }



        private void WatchNodeEvent()
        {
            if (RunningTime == 0)
                ReadyNode.Invoke();
            else
            {
                if (IsRunning)
                    RunningNode.Invoke();
                else
                    ClearNode.Invoke();
            }
        }



        private TimeCounterISMNode() : base(0) { }
        public TimeCounterISMNode(float time) : base(time)
        {
            ReadyNode = new UnityEvent();
            RunningNode = new UnityEvent();
            ClearNode = new UnityEvent();
        }
    }
}
